﻿using Architecture.API.Application.TraceabilityCommand.RawMaterialCommand;
using MediatR;
using Traceability.Domain.Service.RawMaterialServices;
using Traceability.Domain.SupplierDomain;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.RawMaterialCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowRawMaterialCommandHandler : IRequestHandler<ShowRawMaterialCommand, List<RawMaterialDto>>
    {
        /// <summary>
        /// 原料服务
        /// </summary>
        protected readonly IRawMaterialService rawMaterialService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="rawMaterialService">原料服务</param>
        public ShowRawMaterialCommandHandler(IRawMaterialService rawMaterialService)
        {
            this.rawMaterialService = rawMaterialService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<RawMaterialDto>> Handle(ShowRawMaterialCommand request, CancellationToken cancellationToken)
        {
            return await rawMaterialService.GetAllRawMaterialList(request.ShoppingId);
        }
    }
}
